import { IsString, MinLength, Matches, IsPhoneNumber } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';

export class PasswordResetConfirmDto {
  @ApiProperty({
    example: '13812345678',
    description: '用户手机号',
  })
  @IsPhoneNumber('CN', {
    message: '手机号格式不正确，请输入正确的中国大陆手机号',
  })
  phone: string;

  @ApiProperty({
    example: '123456',
    description: '6位数字验证码',
    pattern: '^\\d{6}$',
  })
  @IsString()
  @Matches(/^\d{6}$/, { message: '验证码必须是6位数字' })
  code: string;

  @ApiProperty({
    example: 'NewP@ssw0rd',
    description: '新密码（需包含大小写字母和数字）',
    minLength: 8,
  })
  @IsString()
  @MinLength(8)
  @Matches(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d\W_]{8,}$/, {
    message: '密码必须包含大小写字母和数字',
  })
  newPassword: string;
}
